package restdom.validation.ruleengine.conf;

import java.lang.annotation.Annotation;
import java.util.List;

import org.springmodules.validation.bean.conf.loader.annotation.handler.AbstractClassValidationAnnotationHandler;
import org.springmodules.validation.bean.rule.AbstractValidationRule;

import restdom.ruleengine.RuleSourceResolver;
import restdom.validation.ruleengine.RuleEngineValidationRule;

public class RuleEngineValidationAnnotationHandler extends
		AbstractClassValidationAnnotationHandler {

	private RuleSourceResolver ruleSourceResolver;

	private List<Object> helperObjects;

	public RuleEngineValidationAnnotationHandler() {
		super(RuleEngineValidated.class);
	}

	@Override
	protected AbstractValidationRule createValidationRule(
			Annotation annotation, Class clazz) {

		RuleEngineValidated ruleAnnotation = (RuleEngineValidated) annotation;
		String bindUri = ruleAnnotation.bindUri();
		String source = ruleAnnotation.source();

		return new RuleEngineValidationRule(bindUri, source, clazz,
				ruleSourceResolver, helperObjects);
	}

	public RuleSourceResolver getRuleSourceResolver() {
		return ruleSourceResolver;
	}

	public void setRuleSourceResolver(RuleSourceResolver ruleSourceResolver) {
		this.ruleSourceResolver = ruleSourceResolver;
	}

	public List<Object> getHelperObjects() {
		return helperObjects;
	}

	public void setHelperObjects(List<Object> helperObjects) {
		this.helperObjects = helperObjects;
	}
}
